package com.example.gaoyang.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.gaoyang.domain.request.SysRoleElementRequest;
import com.example.gaoyang.domain.vo.SysRoleElementVO;
import com.example.gaoyang.request.Result;
import com.example.gaoyang.service.SysRoleElementService;
import com.example.gaoyang.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/sysRoleElement")
public class SysRoleElementController {

    @Resource
    private SysRoleElementService sysRoleElementService;

    @PostMapping("/addSysRoleElement")
    public Result addSysRoleElement(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        sysRoleElementService.addSysRoleElement(sysRoleElementRequest);
        return ResultUtil.success("角色添加元素成功");
    }

    @PostMapping("/batchAddSysRoleElement")
    public Result updateSysRoleElement(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        sysRoleElementService.batchAddSysRoleElement(sysRoleElementRequest);
        return ResultUtil.success("角色批量添加系统元素成功");
    }

    @PostMapping("/removeSysRoleElement")
    public Result removeSysRoleElement(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        sysRoleElementService.removeSysRoleElement(sysRoleElementRequest);
        return ResultUtil.success("角色删除系统元素成功");
    }

    @PostMapping("/batchRemoveSysRoleElement")
    public Result batchRemoveSysRoleElement(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        sysRoleElementService.batchRemoveSysRoleElement(sysRoleElementRequest);
        return ResultUtil.success("角色批量删除系统元素成功");
    }

    @PostMapping("/batchUpdateSysRoleElement")
    public Result batchUpdateSysRoleElement(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        sysRoleElementService.batchUpdateSysRoleElement(sysRoleElementRequest);
        return ResultUtil.success("角色更新系统元素成功");
    }

    @PostMapping("/getSysRoleElementList")
    public Result<List<SysRoleElementVO>> getSysRoleElementList(@RequestBody SysRoleElementRequest sysRoleElementRequest) {
        return ResultUtil.success(sysRoleElementService.getSysRoleElementList(sysRoleElementRequest));
    }

    @PostMapping("/getSysRoleElementPage")
    public Result getSysRoleElementPage(Page page, @RequestBody SysRoleElementRequest sysRoleElementRequest) {
        return ResultUtil.success(sysRoleElementService.getSysRoleElementPage(page, sysRoleElementRequest));
    }

}
